public class PhoneNumbers
{
   /**
      Cleans a phone number.
      @param phoneNumber a phone number that should contain ten digits and possibly other characters
      @return the phone number in the form (###) ###-#### or the string "Error" if phoneNumber
      does not have ten digits
   */
   public String cleanNumber(String phoneNumber)
   {   
      // your work here
      String s1="(";
      
      int n=phoneNumber.length();
      
      int s=0;
      int x=1;
      for (int i = 0; i < n; i++)
      {
         char ch = phoneNumber.charAt(i);
         if (Character.isDigit(ch))
         {
            s++;
            s1+=ch;
            
            if(x==3) {
               s1+=") ";
            }
            if(x==6) {
               s1+="-";
            }
            x++;
         }          
      }
      
      if(s!=10) {
         return "Error";
      }  
      
      return s1;
   }   
}